
#main

#php PDOStatement {
	fetch(fetch_style Int = #default) String.Dict
	fetchAll(fetch_style Int = #default) String.Dict.Array
}

#php PDO {
	FETCH_ASSOC Int
	FETCH_COLUMN Int
	construct(dsn String, username String = #default, passwd String = #default, options Dict = #default)
	exec(statement String) Int
	query(statement String) PDOStatement
	quote(string String, parameter_type Int = #default) String
	lastInsertId(name String = #default) String
	errorCode() String
	errorInfo() Array
}

public SQLitePDO: PDO {
	construct(filename String) {
		super.construct('sqlite:${realpath(filename)}')
	}
}

var sqlite = SQLitePDO('$__DIR__/pdo_sqlite.db')
rs = sqlite.query('SELECT name FROM sqlite_master ORDER BY name')
rows = rs.fetchAll(PDO.FETCH_ASSOC)

if not rows {
	sqlite.exec('CREATE TABLE demo (id int,name string)')
	echo 'The demo table created'
}
else {
	var_dump(rows)
}

